home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / utils / lookbibtex / bibdestringify.dist < prev    next >
Text File  |  1993-03-18  |  2KB  |  49 lines

  1. #!/usr/dist/bin/perl
  2.  
  3. #
  4. # bibdestringify 1.02
  5. #   a perl script to remove strings from a bibtex file.
  6. # Comments to <johnh@cs.ucla.edu>.
  7. #
  8. # Copyright (C) 1990 by John Heidemann
  9. # This is distributed under the GNU Public Licence, Version 1 (Feb 89).
  10. # See the Perl documentation for a copy of that license.
  11. #
  12. # Timings (from ./bibdestringify <bibdestringify.example >/dev/null):
  13. # version   time (with /bin/time)
  14. # 0.90      14.6 real        13.8 user         0.2 sys
  15. # 0.91      12.6 real        11.9 user         0.2 sys
  16. # 1.0        1.7 real         1.4 user         0.2 sys
  17. #
  18. # 17-Jan-91 It is begun.  bibdestringify 0.9
  19. # 15-Feb-91 It is documented, and given out to khera@cs.duke.edu.
  20. # 26-Aug-91 Speed slightly improved.  bibdestringify 0.91
  21. # 26-Aug-91 Changed to remember patterns and process with eval.
  22. #       Speed dramatically (order of magnitude) improved.
  23. #       My hat is off to the mighty eval!  bibdestringify 1.0
  24. # 27-Aug-91 Patched to allow a more liberal definition of @strings
  25. #       at the suggestion of Vick Khera <khera@cs.duke.edu>. bibdestringify 1.01
  26. # 11-Sep-91 A positivly radical definition of @strings.  bibdestringify 1.02
  27. #
  28.  
  29.  
  30. $replace = 's/\"\s*\#\s*\"//g;';   # the replacement pattern
  31.         # (default to doing string concatination)
  32.  
  33.  
  34. while (<STDIN>) {
  35.     if (($name,$value) = /\@string\s*{\s*(\S+)\s*=\s*(.*)\s*}/) {
  36.         $name =~ s/(\W)/\\\1/g;   # quote special chars
  37.         $value =~ s/(\W)/\\\1/g;
  38.         $replace = "s/\\b$name\\b/$value/g;\n" . $replace;
  39.     } else {
  40. #        if (!$done) { print "$replace\n"; $done=1; };
  41.         eval $replace;
  42.         $@ && die ("Error in eval, $@");
  43.         print $_;
  44.     };
  45. };
  46.  
  47.  
  48.  
  49.